How to Extract Public Key from .PEM file
Key.pem can contain anything - a certificate with a public key, an SSH public key, public key + private key, certificate with a public key + private key while key.pub contains public key in Open SSH format.
Below are the steps to extract the public key from .pem file to access ec2 servers.
Note: Download “Git” to extract public key(.pub) from .pem file.
Link: https://git-scm.com/downloads
- Access the location where the .pem file is saved.
- Right click on the location and click on select Git Bash Here as shown in the screenshot.
- Execute the below command in the console to extract public key.
ssh-keygen -y -f private_key1.pem > public_key1.pub
Eg. ssh-keygen -y -f jamcracker.pem > jamcracker.pub
- The public key will be extracted in the same location as pem file & the format of the key is ‘.pub’. Open the file with Notepad ++ or Editplus.